Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Deleting persistent procedures
You must clean up persistent procedure instances you have created just as with other objects. Remember that the
RUNprog.pPERSISTENTstatement is much the same asCREATEobject. Progress creates a running instance of the procedure and all its contents, and leaves it in memory until you specifically delete it. The simplest way to delete a procedure when you’re done with it is to use this statement:
Note that you use the
PROCEDUREkeyword in this statement, notOBJECT.The AppBuilder templates observe a convention that is a very useful alternative to simply deleting a procedure. If you delete a procedure from the outside, it might not be finished doing what it needs to do and might not have a chance to clean up the objects inside it properly. It is much more reliable, and much more object-oriented, to tell the procedure to delete itself rather than to simply kill it. You’ve seen the way the AppBuilder-generated procedure handled this earlier, but it’s worth repeating in the context of this discussion about memory management.
The procedure’s main block runs a standard internal procedure called
enable_UIand then waits for aCLOSEevent if the procedure is not being run persistent. If it is being run persistent, then it stays in memory without the need for anyWAIT-FORstatement:
The
WINDOW-CLOSEevent on the window applies the proceduralCLOSEevent to the procedure:
The main block also defines this
CLOSEevent, which runs the cleanup code in thedisable_UIinternal procedure, which again is part of the AppBuilder’s own standard mechanism for starting and stopping procedures:
And finally,
disable_UIdeletes any dynamic objects. Then, if the procedure was run persistent, it explicitly deletes itself. If it wasn’t run persistent, then Progress deletes it for you:
Whether you use the AppBuilder templates or not, use some similar convention that makes sure your procedures clean up after themselves and deletes them when your application is done with them.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |